package com.csi.bumblebee.service.impl;

import com.csi.bumblebee.domain.dictionary.JobExam;
import com.csi.bumblebee.mapper.JobExamMapper;
import com.csi.bumblebee.service.JobExamService;
import com.csi.bumblebee.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author 孙伟俊
 */
@Service
public class JobExamServiceImpl implements JobExamService {

    @Autowired
    private JobExamMapper jobExamMapper;

    @Qualifier("jdkRedisTemplate")
    private RedisTemplate redisTemplate;

    /**
     * 后台增加题目
     * @param jobExam 对象
     * @return 影响行数
     */
    @Override
    public int addJobExam(JobExam jobExam) {
        return jobExamMapper.addJobExam(jobExam);
    }

    public int addJobExam(List<JobExam> jobExamList, String id){

        int result = 0;

        for (JobExam jobExam : jobExamList) {
            jobExam.setCreationBy(id);
            jobExam.setId(IdUtil.getString(JobExam.PRE_NAME));
            result = jobExamMapper.addJobExam(jobExam);
        }
        return result;
    }
}
